<?php include_once($_SERVER['DOCUMENT_ROOT']."/controller/common/common_setting_unit.php");         // 引入通用的设置文件 ?>
<?php include_once($_SERVER['DOCUMENT_ROOT']."/controller/common/module/head.php"); // 引入通用的头部 ?>
<?php include_once("../controller/data_list.php");                     // 当前页面的控制器 ?>



<body>

<!--顶部栏-->
<div id="topbar"> <?php include $_SERVER['DOCUMENT_ROOT'] . '/controller/common/module/topbar.php'; ?></div>

<!--容器-->
<div id="container" class="<?php echo $now_extender ?>">

<!--侧边栏-->
<div id="sidebar"><?php include $_SERVER['DOCUMENT_ROOT'] . '/controller/common/module/sidebar.php'; ?></div>





        <?php
        //==============================================================================
        //这里开始才是平常开发需要注重的部分，其余的基本不用理会
        //==============================================================================
        ?>

  
        <div id="content" class="layui-form">

            <!--标题设定-->
            <?php $page_title=$this_plate['name'].'列表';?>
            <?php include $_SERVER['DOCUMENT_ROOT']. '/controller/common/module/mod-page-title.php'; ?>

            <!--搜索框-->
            <?php include 'module/mod-search.php'; ?>


            <!--功能按钮：新增，统计，全选，排序，导出之类的-->
            <?php include 'module/mod-function.php'; ?>



            <!-- 用$now_extender .list_boxe来控制来到确认板块信息显示-->
            <div class="list-box">

<table class="layui-table layui-form">
    <colgroup>
        <col width="20" >
        <col width="50" >
        <col  >
        <col  >
        <col width="90" >
        <col width="150" >
        <col width="180" >
        <col width="250" >
    </colgroup>
    <thead>
    <tr>
        <th  class="layui-table-cell">
            <input type="checkbox" lay-skin="primary"
                   lay-filter="check_all_checkbox"
                   id="check_all_checkbox" >
        </th>
        <th><div class="els2">图片</div></th>
        <th><div class="els2">名称</div></th>
        <th><div class="els2">介绍</div></th>
        <th><div class="els2">发布状态</div></th>
        <th><div class="els2">备注</div></th>
        <th><div class="els2">创建时间</div></th>
        <th><div class="els2">操作</div></th>

    </tr>
    </thead>
    <tbody>

    <?php for ($i = 0; $i < $_quantity_per_page; $i++) {?>

        <tr id="item<?php echo $data_list_page[$i]['nid'] ?>">

            <td id="<?php echo $i + 1 + $plate['page_list_num'] * ($nowpageid - 1) ?>" class="layui-table-cell">
                    <input type="checkbox" name="nid[]" lay-skin="primary" lay-filter="item_checkbox"  value="<?php echo $data_list_page[$i]['nid'] ?>">
            </td>
            <td><div class="icon" id="icon<?php echo $data_list_page[$i]['nid'] ?>" >
                     <?php if($data_list_page[$i]['icon']){$icon="/uploadfiles/".$data_list_page[$i]['icon'];}
                    else{$icon="/controller/common/asset/image/no_image.jpg";}?>

                    <img src="<?echo $icon?>"
                         style="object-fit: contain; width: 100%;height: 100%"
                         onclick="layer_show_by_id('<?php echo 'icon'.$data_list_page[$i]['nid'] ?>')">
                </div>
            </td>
            <td><div class="els2"><?php echo $data_list_page[$i]['name'] ?></div></td>
            <td><div class="els2"><?php echo $data_list_page[$i]['introduce'] ?></div></td>
            <td>
                <input type="checkbox"  <?php if ($data_list_page[$i]['publish_status'] == "发布") {echo "checked";} ?>
                       lay-skin="switch" value="<?echo $data_list_page[$i]['nid']?>"
                       lay-filter="publish_status"
                       lay-text="是|否">
            </td>

            <td><div class="els1" id="remark"
                     onmouseover="show_remark('<?php echo $data_list_page[$i]['remark'] ?>','remark')"
                     onmouseout="closed_remark('remark')">
                    <?php echo $data_list_page[$i]['remark'] ?>
                </div>
            </td>
            <td><div class="els2"><?php echo $data_list_page[$i]['creat_date'] ?></div></td>


            <td>

                <span onclick="window_eject('data_edit_window.php?<?php echo $data['url_parameter'] ?>&nid=<?php echo $data_list_page[$i]['nid'] ?>')"
                   class="layui-btn  layui-btn-sm">
                    <i class="fa fa-edit" aria-hidden="true" /></i> 修改
                </span>

                <a onclick="window_eject('data_info_window.php?<?php echo $data['url_parameter'] ?>&nid=<?php echo $data_list_page[$i]['nid'] ?>')"
                   class="layui-btn  layui-btn-sm">
                    <i class="fa fa-file-text-o" aria-hidden="true" /></i> 信息
                </a>


                <span
                        onclick="deleter(<?php echo $data_list_page[$i]['nid'] ?>,'data_delete_process')"
                        class="layui-btn layui-btn-sm layui-btn-primary">
                    <i class="fa fa-trash-o" aria-hidden="true" /></i> 删除
                </span>
            </td>


        </tr>
    <?php ;} ?>

    <?php //无数据时显示
        if (count($data_list_page) == 0) { echo "<tr class='no_data'><td colspan='15'>暂无数据</td></tr>"; }
    ?>

    </tbody>
</table>





                <!-- 翻页代码-->
                <?php include ROOT_PATH_ . '/controller/common/module/mod_page_numbers.php'; ?>



            </div>
            <!--list-box end-->


        </div>
        <!--content端點01-->
        <?
        //==============================================================================
        //这里上面才是平常开发需要注重的部分，下面的基本不用理会，只有底部JS部分需要根据实际情况去加载
        //==============================================================================
        ?>





<br class="clearfloat"/>
<!--container-->
</div>




<!--底部栏-->
<?php include ROOT_PATH_ . "/controller/common/module/footer.php"; ?>


<!--载入删除功能-->
<script type="text/javascript" src="/controller/common/asset/js/deleter.js"></script>

<!--载入弹出窗口功能-->
<script type="text/javascript" src="/controller/common/asset/js/window_eject.js"></script>

<!--载入layer弹出元素功能-->
<script type="text/javascript" src="/controller/common/asset/js/layer_show_by_id.js"></script>

<!--载入弹checkbox全选功能；在layui内部实现-->
<script type="text/javascript" src="/controller/common/asset/js/check_all_checkbox.js"></script>

<!--载入弹checkbox全选功能；在layui内部实现-->
<script type="text/javascript" src="/controller/common/asset/js/update_data_publish_status.js"></script>

<!--批量删除按钮的检测-->
<script type="text/javascript" src="/controller/common/asset/js/mulity_delete_button.js"></script>
<!--批量删除功能-->
<script type="text/javascript" src="/controller/common/asset/js/mulity_delete.js"></script>


<script>
    //layui渲染过的元素，需要在这里写函数

    layui.use('form', function(){
        var form = layui.form;

        //layui中，处理checkbox
        check_all_checkbox(form)

        //监控复选框，选择一个就触发删除按钮
        mulity_delete_button(form)

        //监控switch按钮
        form.on('switch(publish_status)', function(data)
        {
            //console.log(data.elem); //得到checkbox原始DOM对象
            console.log(data.elem.id); //开关是否开启，true或者false
            //console.log(data.elem.checked); //开关是否开启，true或者false
            //console.log(data.value); //开关value值，也可以通过data.elem.value得到
            update_data_publish_status(data.value,data.elem.checked)
        });


    });
</script>




</body>
</html>
